﻿<template>
	<div style="padding:0px;">
		<el-form :model="dialogForm" :rules="rules" ref="dialogForm" :label-width="formLabelWidth">
		<el-card class="box-card">
		  
		  <div  class="text item">
			
			  	<div slot="header" class="clearfix">
		          <span style="line-height: 30px;">保证金信息</span>
		        </div>
			    <el-form-item label="经销商名称" >
			      <el-input v-model="dialogForm.qckx" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="购车总价格" >
			      <el-input v-model="dialogForm.qcsl" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="定金金额" >
			      <el-input v-model="dialogForm.qcys" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="借款时长" >
			      <el-input v-model="dialogForm.qcys" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="垫资金额" >
			      <el-input v-model="dialogForm.qcsl" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="保证金状态" >
			      <el-input v-model="dialogForm.qcsl" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="保证金金额" >
			      <el-input v-model="dialogForm.qcsl" auto-complete="off" disabled></el-input>
			    </el-form-item>
			     <el-form-item label="保证金备注" >
			      <el-input type="textarea" :rows=3 v-model="dialogForm.qcys" auto-complete="off" disabled></el-input>
			    </el-form-item>
			</div>
		</el-card>
	    <el-card class="box-card" style="margin-top:15px;">
		  
		  <div  class="text item">
			
			  	<div slot="header" class="clearfix">
		          <span style="line-height: 30px;">保证金信息表单</span>
		        </div>
			    <!-- <el-form-item label="保证金状态" >
			      <el-input v-model="dialogForm.qcsl" auto-complete="off" :disabled="!dialogSendData.isAdd"></el-input>
			    </el-form-item>
			     <el-form-item label="保证金金额" >
			      <el-input v-model="dialogForm.qcys" auto-complete="off" :disabled="!dialogSendData.isAdd"></el-input>
			    </el-form-item> -->
			     <el-form-item label="保证金凭证照片" >
			      <qiniu  :qiniuImage="qiniuImage"  :packJson="packJson" :id="qiniuImage.id" :canDelete="dialogSendData.isAdd"></qiniu>
			    </el-form-item>
			    
			    <el-form-item label="给资金方凭证" >
			      <qiniu  :qiniuImage="qiniuImage1"  :packJson="packJson" :id="qiniuImage1.id" :canDelete="dialogSendData.isAdd"></qiniu>
			    </el-form-item>
			   
			    <el-form-item label="审核信息"  v-if="dialogSendData.isAdd">
			    	<el-radio-group v-model="dialogForm.qckx" :disabled="!dialogSendData.isAdd">
			    				      <el-radio label="审核通过" value="1"></el-radio>
			    				      <el-radio label="审核不通过" value="2"></el-radio>
			    				    </el-radio-group>
			    </el-form-item>
			    <el-form-item label="审核备注" >
			      <el-input type="textarea" :rows=3 v-model="dialogForm.qcys" auto-complete="off" :disabled="!dialogSendData.isAdd"></el-input>
			    </el-form-item>
			   
			</div>
		</el-card>
		<div style="text-align:right;margin-top:15px;">
			 <el-button @click="returnBack">返 回</el-button>
			 <el-button v-if="dialogSendData.isAdd" type="primary" @click="submitConfirmForm('dialogForm')">提 交</el-button>
		</div>
		</el-form>
	</div>
</template>
<script>
    import qiniu from '@/views/qiniu/upload'
	export default{
		created(){
   
        },
		props:['dialogSendData','tableData'],
		components:{qiniu},
		data(){
			
			return{
				formLabelWidth:'170px',
				//弹窗或者查看页面信息
		        dialogForm:{
		          qcsl:"",
		          qckx:"",
		          qcys:"",
		          zdj_pz:"",
		          qczjg:"",
		          dzje:"",
		          resource:""
		        },
		        rules: {
		          name: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
		          qckx:[{ required: true, message: 'qckx', trigger: 'blur' }]
		        },
		         //七牛图片上传
		        qiniuImage:{
		        	id:"qiniuImage", //图片预览的id   
		        	image_uri:[]    //图片上传的列表  只含有url地址
		        },
		         qiniuImage1:{
		        	id:"qiniuImage1", //图片预览的id   
		        	image_uri:[]    //图片上传的列表  只含有url地址
		        },
		        packJson:{
					maxLength:3,   //最大图片数量
					accept:"",//image/gif,image/jpeg,image/jpg,image/png如果是这些，可以不传此参数
					size:4    //图片大小  单位兆
				}
			}
		},methods:{
			submitConfirmForm(formName){
                this.$refs[formName].validate((valid) => {
		          if (valid) {
		          	
		            this.editData();

		          	setTimeout(()=>{
	            		this.dialogSendData.dialogFormVisible=false;
	            	},500)
		          } else {
		            this.$nextTick(()=>{
		          		this.$message.warning(document.getElementsByClassName('el-form-item__error')[0].innerText||"提交失败");
		                return false;
		          	})
		          }
		        });
			},
		    
		    editData(){
		    	this.dialogForm.imagUrl=this.qiniuImage.image_uri.join(",")
		        agentHttp.putJson('adminApi/admin/carousel/put_validated',this.dialogForm).then((data)=>{
		            if(data.success){  
		            	this.$emit('refreshTableData', null);
		            	this.$message.success(data.data||"提交成功");
		            } 
		        }) 
		    },
		    selectData(){
		    	//console.log('取消下方注释，修改请求地址')
		        agentHttp.get('adminApi/admin/carousel/select_carousel/'+this.dialogSendData.id).then((data)=>{	
		            if(data.success){  
		            	this.dialogForm=data.data;
		            	this.qiniuImage.image_uri=data.data.imagUrl.split(',').notempty()//去掉为空的项，不然导致图片张数控制不准
		            } 
		        }) 
		    },
			returnBack(){
				this.dialogSendData.dialogFormVisible=false;
			}
		}
	};
	
</script>